﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using Tools.Debugging;

namespace repliback4.Net.ClientSide {
    public class Server {
        public ClientConnection connection;
        public Server ( TcpClient client ) {
            this.connection = new ClientConnection( client );
            this.connection.OnConnect += new AsyncConnection.OnConnectHandler( connection_OnConnect );
            this.connection.OnDisconnect += new AsyncConnection.OnDisconnectHandler( connection_OnDisconnect );
            this.connection.OnReceive += new AsyncConnection.OnReceiveHandler( connection_OnReceive );
            this.connection.OnRemoteDisconnect += new AsyncConnection.OnRemoteDisconnectHandler( connection_OnRemoteDisconnect );
            
        }

        //public void 

        void connection_OnRemoteDisconnect ( RemoteDisconnectData data ) {
            Logger.Debug( this, "remote host disconnected" );
        }

        void connection_OnConnect ( ConnectData data ) {
            //throw new NotImplementedException( );
            
        }

        void connection_OnDisconnect ( DisconnectData data ) {
            //throw new NotImplementedException( );
        }

        void connection_OnReceive ( Response response ) {
            //throw new NotImplementedException( );
            Logger.Debug( this, response.Data );
        }
    
        internal void Send(string message)
        {
 	        this.connection.Send(message);
        }
    }
}
